package com.tanhua.server.controller;

import com.tanhua.domain.vo.AnswersVo;
import com.tanhua.server.service.TestSoulService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author 胡少东
 * @create 2021/8/6 17:11
 */
@RestController
@RequestMapping("/testSoul")
public class TestSoulController {

    @Autowired
    private TestSoulService testSoulService;

    /**
     * 获取所有灵魂试题
     * @return
     */
    @GetMapping
    public ResponseEntity<Object> testSoulList () {
        return testSoulService.testSoulList();
    }

    /**
     * 将用户答题 收集之后 统计分数 显示最后的性格列表
     * @param answers
     * @return
     */
    @PostMapping
    public ResponseEntity<String> submitTest(@RequestBody Map<String, List<AnswersVo>> answers) {
        return testSoulService.submitTest(answers);
    }

    @GetMapping("/report/{id}")
    public ResponseEntity<Object> report(@PathVariable("id")Long id) {
        return testSoulService.getTest(id);
    }

}